<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui, viewport-fit=cover">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>My App</title>
    <link rel="stylesheet" href="../../packages/core/css/framework7.min.css">
    <link rel="stylesheet" href="../../css/framework7-icons.css">
  </head>
  <body>
    <div id="app"></div>
    <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
    <script src="https://unpkg.com/react@16.4.1/umd/react.production.min.js"></script>
    <script src="https://unpkg.com/react-dom@16.4.1/umd/react-dom.production.min.js"></script>
    <script src="../../packages/react/framework7-react.min.js"></script>
    <script src="../../packages/core/js/framework7.min.js"></script>
    <script type="text/babel">
      class LoginScreenPage extends React.Component {
        constructor() {
          super();
      
          this.state = {
            username: '',
            password: '',
          };
        }
        signIn() {
          const self = this;
          const app = self.$f7;
          const router = self.$f7router;
          app.dialog.alert(`Username: ${self.state.username}<br>Password: ${self.state.password}`, () => {
            router.back();
          });
        }
        render() {
          return (
            <Page noToolbar noNavbar noSwipeback loginScreen>
              <LoginScreenTitle>Framework7</LoginScreenTitle>
              <List form>
                <ListInput
                  label="Username"
                  type="text"
                  placeholder="Your username"
                  value={this.state.username}
                  onInput={(e) => {
                    this.setState({ username: e.target.value});
                  }}
                />
                <ListInput
                  label="Password"
                  type="password"
                  placeholder="Your password"
                  value={this.state.password}
                  onInput={(e) => {
                    this.setState({ password: e.target.value});
                  }}
                />
              </List>
              <List>
                <ListButton onClick={this.signIn.bind(this)}>Sign In</ListButton>
                <BlockFooter>Some text about login information.<br />Lorem ipsum dolor sit amet, consectetur adipiscing elit.</BlockFooter>
              </List>
            </Page>
          )
        }
      }
      
      const routes = [{
        path: '/login-screen-page/',
        component: LoginScreenPage,
      }];
      
      class AppComponent extends React.Component {
        constructor() {
          super();
      
          this.state = {
            loginScreenOpened: false,
            username: '',
            password: '',
          };
        }
        signIn() {
          const self = this;
          const app = self.$f7;
      
          app.dialog.alert(`Username: ${self.state.username}<br>Password: ${self.state.password}`, () => {
            app.loginScreen.close();
          });
        }
        render() {
          return (
            <App routes={routes}>
              <View main>
                <Page>
                  <Navbar title="Login Screen"></Navbar>
                  <Block>
                    <p>Framework7 comes with ready to use Login Screen layout. It could be used inside of page or inside of popup (Embedded) or as a standalone overlay:</p>
                  </Block>
      
                  <List>
                    <ListItem link="/login-screen-page/" title="As Separate Page"></ListItem>
                  </List>
      
                  <Block>
                    <Button raised big fill loginScreenOpen=".demo-login-screen">As Overlay</Button>
                  </Block>
      
                  <Block>
                    <Button raised big fill onClick={() => {this.setState({loginScreenOpened : true})}}>Open Via Prop Change</Button>
                  </Block>
      
                  <LoginScreen className="demo-login-screen" opened={this.state.loginScreenOpened} onLoginScreenClosed={() => {this.setState({loginScreenOpened : false})}}>
                    <Page loginScreen>
                      <LoginScreenTitle>Framework7</LoginScreenTitle>
                      <List form>
                        <ListInput
                          label="Username"
                          type="text"
                          placeholder="Your username"
                          value={this.state.username}
                          onInput={(e) => {
                            this.setState({ username: e.target.value});
                          }}
                        />
                        <ListInput
                          label="Password"
                          type="password"
                          placeholder="Your password"
                          value={this.state.password}
                          onInput={(e) => {
                            this.setState({ password: e.target.value});
                          }}
                        />
                      </List>
                      <List>
                        <ListButton onClick={this.signIn.bind(this)}>Sign In</ListButton>
                        <BlockFooter>Some text about login information.<br />Lorem ipsum dolor sit amet, consectetur adipiscing elit.</BlockFooter>
                      </List>
                    </Page>
                  </LoginScreen>
                </Page>
              </View>
            </App>
          )
        }
      }
    </script>
    <script>
      var theme = 'ios';
      if (location.href.indexOf('theme=md') >= 0) theme = 'md';
      
      if (Framework7.use) Framework7.use(Framework7React, { theme: theme });
      else if (Framework7.Class && Framework7.Class.use) Framework7.Class.use(Framework7React, { theme: theme });
      
      var plugin = {
        params: {
          theme: theme,
        }
      };
      
      if (Framework7.use) Framework7.use(plugin);
      else if (Framework7.Class && Framework7.Class.use) Framework7.Class.use(plugin);
      
      window.onload = function () {
        if (typeof AppComponent !== 'undefined') {
          ReactDOM.render(
            React.createElement(AppComponent),
            document.getElementById('app')
          );
        }
      }
    </script>
  </body>
</html>